package com.shengwei.truck.driver.view.selfview.chart;

import com.github.mikephil.charting.charts.BarLineChartBase;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.shengwei.truck.driver.utils.MyLogCat;

/**
 * Created by xw.gao
 */
public class XAxisWeekValueFormatter implements IAxisValueFormatter {
    String TAG = "XAxisWeekValueFormatter";
    private final BarLineChartBase<?> chart;
    private int mChartType;  //1周，2年

    public XAxisWeekValueFormatter(BarLineChartBase<?> chart, int chartType) {
        this.chart = chart;
        mChartType = chartType;
    }

    public BarLineChartBase<?> getChart(){
        return chart;
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        int days = (int) value;
        MyLogCat.i(TAG, "value=" + value);
        String xLabel = null;
        switch (days) {
            case 1:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周一";
                }
                break;
            case 2:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周二";
                }
                break;
            case 3:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周三";
                }
                break;
            case 4:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周四";
                }
                break;
            case 5:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周五";
                }
                break;
            case 6:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周六";
                }
                break;

            case 7:
                if (mChartType == 2) {
                    xLabel = days + "月";
                } else {
                    xLabel = "周日";
                }
                break;
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
                xLabel = days + "月";
                break;

        }
        return xLabel;
    }
}
